package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.tanhua.domain.db.Settings;
import com.tanhua.dubbo.mapper.SettingMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service//注册zoo
public class SettingApiImpl implements SettingApi {
//    注入SettingMapper对象
    @Autowired
    private SettingMapper settingMapper;

    /**
     * 根据ID查询设置表
     * @param id
     * @return
     */
    @Override
    public Settings getSettingById(Integer id) {
        LambdaQueryWrapper<Settings> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Settings::getUserId,id);
        return  settingMapper.selectOne(queryWrapper);
    }
    /**
     * 保存设置信息
     * @param settings
     */
    @Override
    public void save(Settings settings) {
        settingMapper.insert(settings);
    }

    /**
     * 更新设置信息
     * @param settings
     */
    @Override
    public void update(Settings settings) {
        settingMapper.updateById(settings);
    }

    }


